<!doctype html>
<html>
<head>
	<title>使用ajax获取node.js服务器数据</title>
	<meta charset="utf8">
	<script type="text/javascript">

		function getData(){
			var xhr = new XMLHttpRequest();
			xhr.open("GET", "http://localhost:1337/", true);
			xhr.onreadystatechange = function(){
				if(xhr.readyState == 4){
					if(xhr.status == 200){
						document.getElementById("div").innerHTML = xhr.responseText;
					}
				}
			}
			xhr.send(null);
		}

	</script>
</head>
<body>
	<input type="button" value="获取数据" onclick="getData()" />
	<div id="div"></div>
</body>
</html>